﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net.Mail;
using System.Net;


namespace BusinessLogicLayer
{
    public class EmailNotificationControl
    {
        

        public void sendNotification(string toemail, string fromemail, string body, string subject)
        {
            MailMessage mailMessage = new MailMessage(fromemail, toemail);
            SmtpClient smtpClient = new SmtpClient("lynx.iss.nus.edu.sg");

            try
            {
                mailMessage.Subject = subject;
                mailMessage.Body = body; 

                smtpClient.Send(mailMessage);
                smtpClient.Dispose();   
            }
            catch (Exception ex)
            {
               
            }
        }

        public void sendHtmlEmail(string fromEmail, string toEmail, string subject, string body)
        {
            MailMessage msg = new MailMessage(fromEmail, toEmail);
            SmtpClient smtpClient = new SmtpClient("lynx.iss.nus.edu.sg");
            try
            {    
                msg.Subject = subject;
                msg.Body = body;
                msg.IsBodyHtml = true; 

                smtpClient.Send(msg);
                smtpClient.Dispose();
            }
            catch (Exception ex)
            {
            }

            //SmtpClient smtpClient = new SmtpClient();
            //MailMessage msg = new MailMessage();

            //try
            //{
            //    msg.To.Add(toEmail); 
            //    msg.Subject = subject;    
            //    msg.IsBodyHtml = true;
            //    msg.Body = body;

            //    smtpClient.EnableSsl = true;
            //    smtpClient.Send(msg);
            //    smtpClient.Dispose();
            //}
            //catch (Exception ex)
            //{
            //}
        }
    }
}
